package com.huwei.util;

import java.util.Random;


public class SmsCode  {
	/*
	 * 短信验证码基数
	 */
	static final private int[] BASE_NUMBER = new int[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
	/*
	 * 短信验证码长度
	 */
	static final private int SMS_CODE_LENGTH = 6;

	static public String randomCode() {
		return randomCode(SMS_CODE_LENGTH);
	}
	
	static public String randomCode(int codeLength) {
		StringBuffer result = new StringBuffer();
		Random random = new Random();
		for (int i = 0; i < codeLength; ++i) {
			result.append(BASE_NUMBER[random.nextInt(10)]);
		}
		return result.toString();
	}
}
